package com.java.jvm.loader;

/**
 * 获取类的加载体系(常用类加载器有哪些)
 */
public class ClassLoaderTypeTests {
    public static void main(String[] args) {
        //获取应用类加载器(我们自己写类默认都是通过这个类加载器加载的)
        ClassLoader systemClassLoader =
                ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);//AppClassLoader
        //获取扩展类加载器-负载加载jre中的扩展类库
        ClassLoader extClassLoader = systemClassLoader.getParent();
        System.out.println(extClassLoader);//ExtClassLoader
        //获取启动类加载器(根类加载器)-负责加载jre中的基础类库
        ClassLoader bootClassLoader=extClassLoader.getParent();//null (c/c++)
        System.out.println(bootClassLoader);//null (BootStrapClassLoader)

        ClassLoader stringClassLoader =
                String.class.getClassLoader();
        System.out.println(stringClassLoader);//null

        ClassLoader classLoader = ClassLoaderTypeTests.class.getClassLoader();
        System.out.println(classLoader);

    }
}
